import { TIME_STAMP, TOKEN_TIMEOUT_VALUE } from "@/constant";
import { getItem, setItem } from "./storage";

// 获取时间戳
export function getTimeStamp() {
    return getItem(TIME_STAMP)
}

// 设置时间戳
export function setTimeStamp() {
    setItem(TIME_STAMP, Date.parse(new Date())/1000)
}

// 检查是否超时
export function isCheckTimeout(){
    // 当前时间戳
    var currentTime = Date.parse(new Date())/1000
    // 缓存时间戳
    var timeStamp = getTimeStamp()
    return currentTime - timeStamp > TOKEN_TIMEOUT_VALUE
}
